<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ page import="entities.Comment"%> 
<%@ page import="java.lang.*"%> 

<jsp:useBean id="id" class="java.lang.String" scope="session"/>

<%--<jsp:useBean id="rateMoyenne" class="java.lang.Integer" scope="request"/> --%>
<jsp:useBean id="comments" class="java.util.Vector" scope="request"/>
<%@include file="header.jsp"%>
<script language="JavaScript">
	function add(){

		var idEvent=document.getElementById("idEvent").value;
		var idUser=document.getElementById("idUser").value;
		window.location.href="SerEvent?types=participer&idEvent="+idEvent+"&idParticipant="+idUser;
	}
	function noParticiper(){
		var idEvent=document.getElementById("idEvent").value;
		var idUser=document.getElementById("idUser").value;
		window.location.href="SerEvent?types=noparticiper&idEvent="+idEvent+"&idParticipant="+idUser;
		
	}
	function showMaps(){
		var place=document.getElementById("btnMap").value;
	
		window.open ("map.jsp?place="+place, "new windows", "height=400, width=400, top=300,left=400, toolbar=no,  menubar=no, scrollbars=no, resizable=no,location=no, status=no")  
	}

	
</script> 
 
	<%Event event = (Event)request.getSession().getAttribute("nEvent");
							
		request.getSession().setAttribute("nEvent",event);
		String participerId=(String)request.getSession().getAttribute("id");
		String typesUser = (String)request.getAttribute("typesUser")==null?"":(String)request.getAttribute("typesUser");
							%>
	<input  type="hidden" id="idEvent" value=<%=event.getIdEvent()%>  >
 	<input  type="hidden" id="idUser" value=<%=participerId%>  >
    <div id="formulaire">

    <h3>Informations</h3>
        <%
            Category category = event.getCategory();
            User auteur = event.getPromoters();
        %>
           
       <p>  You are here : /<%=category.getName()%></a>
            /<%=event.getName()%></a></p>
       <p><label>Nom: </label><%=event.getName()%></p>
       <p><label>Description: </label><%=event.getDescription()%></p>
       <p><label>Organisateur: </label><%=event.getPromoters().getUser()%></a></p>
       <%--<p><label>Note Moyenne</label><%=rateMoyenne%>/10</p> --%>
	
    	<p>place
    	<input type="button" id="btnMap" onclick="showMaps()" value="<%=event.getPlace() %>"/></p><br>
   
		
	
	<% 
			if("MyFutureEvents".equals(typesUser)){
    %>	
		<input type="button" name="btnNO" onclick="noParticiper()" value=" Ne pas Participer cet Event">
    <% 
		}
			else{%>
				<input type="button" name="btnAdd" onclick="add()" value="Participer cet Event">
			<% }
		if("MyOrganisedEvents".equals(typesUser)){
	%>
			<input type="button" name="btnDel" onclick="supprimer()" value="supprimer cet Event">
	<% 		
		}
	%>
        

            <% if (!(id.isEmpty()) && !id.equals("")) { %>

            <fieldset>
            <h3>Commentez cet event</h3>

                <form action="CommentEvent" method="post">
                <p><label>Message</label><textarea name="message" cols="40" rows="5"></textarea></p>
                <p><input type="hidden" name="userId" value="<%=String.valueOf(id)%>"/>;
                <input type="hidden" name="eventId" value="<%=String.valueOf(event.getIdEvent())%>"/>
                <input id="button" type="submit" name="message" value="message"/></p>
            </form>
            
            <form action="showEvent.jsp" method="post">
            
            </form>

            </fieldset>
                
        <%      } else { %>
            <h3>Il faut se loguer pour commenter...</h3>
        <%      } %>
        


            <h3>Commentaires</h3>
        <%
            if (!comments.isEmpty()) {

                java.util.Iterator it3 = comments.iterator();
                while (it3.hasNext()) {
                    Comment comment = (Comment) it3.next();
                    %>
                    <p><label><%=comment.getUser().getUser()%>"></label><%= comment.getComment() %></p>
                    <%      }
            } else {
                out.print("<p>Pour le moment, personne n'a encore commenté cet event.</p>");
            }
        %>
        </div>
</body>